package com.gxa.controller;

import com.gxa.pojo.TenantBill;
import com.gxa.service.impl.TenantBillServiceImpl;
import com.gxa.service.TenantBillService;
import com.gxa.utils.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "租户账单管理控制器")
@RequestMapping("/tenantBill")
public class TenantBillController {

    @Autowired
    private TenantBillServiceImpl tenantBillService;

    @PostMapping("/addTenantBill")
    @ApiOperation("新增租户账单")
    public ResponseData addTenantBill(@ApiParam(value = "新增租户实体类信息",required = true) @RequestBody TenantBill tenantBill){

        if(tenantBillService.addTenantBill(tenantBill)){
            return new ResponseData(1,"添加成功");
        }else{
            return new ResponseData(0,"添加失败");
        }
    }

    @ApiOperation("显示所有租户账单")
    @GetMapping("/showAllTenantBillByPage")
    public ResponseData showAllTenantBillByPage(@ApiParam(value = "显示第几页",required = true) int pageNum,@ApiParam(value = "一页显示几组数据",required = true) int pageSize){

        return new ResponseData(11,"查询成功",tenantBillService.getCount(),tenantBillService.showAllTenantBillByPage(pageNum, pageSize));
    }

    @ApiOperation("根据租户账单编号删除账单")
    @DeleteMapping("/deleteByBillNumber")
    @ResponseBody
    public ResponseData deleteTenantBillByBillNumber(@ApiParam(value = "要删除租户账单的编号",required = true) String billNumber){

        if(tenantBillService.deleteByBillNumber(billNumber)){
            return new ResponseData(1,"删除成功");
        }else {
            return new ResponseData(0,"删除失败");
        }
    }

}
